package com.nbot.server.util;

import com.nbot.server.domain.KeyParameterLogDO;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by lovewinner on 2018/6/21.
 */
public class KeyParameterMonthUtil {
    public static BigDecimal getMax(List<KeyParameterLogDO> kpmLogs) {
        BigDecimal max = BigDecimal.ZERO;
        for (KeyParameterLogDO kpm : kpmLogs) {
            if (kpm.getKeyParameterValue().compareTo(max) == 1) {
                max = kpm.getKeyParameterValue();
            }
        }
        return max;
    }

    public static BigDecimal getMin(List<KeyParameterLogDO> kpmLogs) {
        BigDecimal min = kpmLogs.get(0).getKeyParameterValue();
        for (KeyParameterLogDO kpm : kpmLogs) {
            if (kpm.getKeyParameterValue().compareTo(min) == -1) {
                min = kpm.getKeyParameterValue();
            }
        }
        return min;
    }

    public static BigDecimal getSum(List<KeyParameterLogDO> kpmLogs) {
        BigDecimal sum = kpmLogs.get(0).getKeyParameterValue();
        for (KeyParameterLogDO kpm : kpmLogs) {
            sum = sum.add(kpm.getKeyParameterValue());
        }
        return sum;
    }
}
